package com.lmq.DependencyInversion.pro;

public class DepenInver {
    public static void main(String[] args) {
        Person person = new Person();
        person.receive(new Email());
        person.receive(new WeiXin());

    }
}
// define IReceiver
interface IReceiver{
    public String getInfo();

}
class Email implements IReceiver {
    public String getInfo(){
        return "电子邮件信息： hello world!!!";
    }
}
// ADD weixin
class WeiXin implements IReceiver{

    @Override
    public String getInfo() {
        return "微信信息： hello mark!!";
    }
}
//完成Person接收消息的功能
// way 1
// 如果接收微信 短信，需要增加额外的类，Person也要增加方法
// solution : introduce a interface IReceiver,表示接收者，
// Person 和IReceiver发生依赖
// Email weixin等实现IReceiver就OK

class Person{
    public void receive(IReceiver iReceiver){
        System.out.println(iReceiver.getInfo());

    }
}

